package com.eurasia.assignment.infrastructure.repository.adapter;

import org.springframework.stereotype.Component;

import com.eurasia.assignment.domain.ProjectAssignment;
import com.eurasia.assignment.infrastructure.entity.ProjectAssignmentEntity;
import com.eurasia.assignment.infrastructure.repository.ProjectAssignmentRepository;
import com.eurasia.assignment.service.port.out.ProjectAssignmentPort;

import lombok.RequiredArgsConstructor;

@Component
@RequiredArgsConstructor
public class ProjectAssignmentPersistentAdapter implements ProjectAssignmentPort {
    
    private final ProjectAssignmentRepository projectAssignmentRepository;
    
    @Override
    public ProjectAssignment getAssignmentByProjectId(Long id) {
        return projectAssignmentRepository.findByProjectId(id)
                .map(ProjectAssignmentEntity::toDomain)
                .orElse(null);
    }
}
